Skip to content

Bump ktir-mlir-frontend past the ktdp.memory_space rename - #108

Merged
fabianlim merged 4 commits into
torch-spyre:mainfrom
fabianlim:bump-ktir
Aug 18, 2026
Merged

Bump ktir-mlir-frontend past the ktdp.memory_space rename#108
fabianlim merged 4 commits into
torch-spyre:mainfrom
fabianlim:bump-ktir

Conversation

@fabianlim

Copy link
Copy Markdown
Collaborator

Bumps ktir-mlir-frontend from 973d67e to ed069fb6 (upstream main) and adapts this repo to two breaking changes in that range.

The motivating change is a3d6bd1, which replaces ktdp.spyre_memory_space with ktdp.memory_space. Getting past that rename is the point of this PR; the source restructuring came along the way and is split into its own commit.

Commits

9c3084c5 Submodule → 05e7a0f; adapt to source restructuring (7 files)
58fdedd5 Fix the one remaining include in triton_spyre.cc
85f36260 Submodule → ed069fb6; migrate off ktdp.spyre_memory_space (20 files)

Reviewing commit-by-commit is easier than the squashed diff — the first two are pure include-path moves, the third is the semantic change.

1. Source restructuring (05e7a0f)

KTDP's public headers moved, so every consumer needs its includes rewritten:

Ktdp/KtdpOps.hpp      → ktir/Dialect/KTDP/KTDP.h
Ktdp/KtdpDialect.hpp  → ktir/Dialect/KTDP/KTDPDialect.h
Ktdp/KtdpAttrs.hpp    → ktir/Dialect/KTDP/KTDPAttrs.h
Ktdp/KtdpTypes.hpp    → ktir/Dialect/KTDP/KTDPTypes.h

No CMake change was needed: add_ktir_library still sets EXPORT_NAME KtdpDialect and _install_ktir_library still creates the KTIR::KtdpDialect alias, so existing link lines resolve unchanged.

triton_spyre.cc is a separate commit because it was missed initially — it's a .cc file, and it compiles into libtriton rather than spyre-triton-opt, so a lit-only check can't catch it. Worth remembering for the next bump.

2. spyre_memory_spacememory_space (a3d6bd1)

Not just a rename — the attribute's enum changed meaning:

old:  #ktdp.spyre_memory_space<HBM>     kind enum {unspecified, LX, HBM}
new:  #ktdp.memory_space<global>        kind enum {global, ct_local}

The C++ parameter value became kind, and core became the optional ct_id. HBM maps to global — taken from upstream's own migration of test/Dialect/KTDP/add.mlir rather than inferred, since the two enums don't correspond term-by-term. If that mapping is wrong for a Spyre-specific reason, this is the commit to revisit.

Changes:

  • 2 C++ construction sites (LowerDescriptorMemory, LowerScalarLoad)
  • 18 .mlir test files, 187 occurrences, all the single form spyre_memory_space<HBM>

Nothing here referenced the deleted KTDPAttrInterfaces.h.

Also in this range

Testing

  • spyre-triton-opt builds clean against the Spyre LLVM
  • lit: 34/34 passed
  • pytest: 1146 passed, 47 skipped, 0 failed

The 3 inter_tile_reduce numerical failures that were present before this PR are also resolved — they were stale bindings, not a code issue.

fabianlim and others added 3 commits August 14, 2026 20:30
Moves the submodule from 973d67e to 05e7a0f (4 commits), whose tip is
"Source structure refactoring (issue torch-spyre#37) (torch-spyre#46)". That refactor relocates
the KTDP public headers, so every consumer here needs its includes
rewritten:

  Ktdp/KtdpOps.hpp            -> ktir/Dialect/KTDP/KTDP.h
  Ktdp/KtdpDialect.hpp        -> ktir/Dialect/KTDP/KTDPDialect.h
  Ktdp/KtdpAttrs.hpp          -> ktir/Dialect/KTDP/KTDPAttrs.h
  Ktdp/KtdpTypes.hpp          -> ktir/Dialect/KTDP/KTDPTypes.h

No CMake change is needed: add_ktir_library still sets
EXPORT_NAME KtdpDialect and _install_ktir_library still creates the
KTIR::KtdpDialect alias, so existing link lines resolve unchanged. The
LLVM pin (cmake/llvm-hash-spyre.txt, e9846648) is identical on both
sides, so no LLVM rebuild is implied.

The `groups`-folded-into-!ktdp.tile_future syntax change was already
present at the previous pin and the lit expectations here already match
it, so no test updates were required.

Verified: spyre-triton-opt builds clean against the Spyre LLVM, and the
lit suite passes 34/34.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Yu Chin Fabian Lim <flim@sg.ibm.com>
…turing

triton_spyre.cc was missed by the include rewrite in 9c3084c: it is a
.cc file, and the sweep that found the other seven consumers only
matched .cpp/.h. It is compiled into libtriton rather than
spyre-triton-opt, so the lit-only verification in that commit did not
cover it — the failure surfaces on `uv pip install -e .` as:

  triton_spyre.cc:10:10: fatal error: 'Ktdp/KtdpDialect.hpp' file not found

Verified: the editable install now builds libtriton clean and
`import triton` resolves to this checkout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Yu Chin Fabian Lim <flim@sg.ibm.com>
Moves the submodule 05e7a0f -> ed069fb6, picking up three commits:

  3da565b  [Ktdp] Add KtirCheckLegality pass stub
  a3d6bd1  Remove KtdpMemorySpaceAttr interface, replace
           ktdp.spyre_memory_space with ktdp.memory_space
  ed069fb  Add the `spyreop` dialect (torch-spyre#57)

a3d6bd1 is a breaking change and the reason for this bump. It is not just a
rename — the attribute's enum changed meaning:

  old: #ktdp.spyre_memory_space<HBM>     kind enum {unspecified, LX, HBM}
  new: #ktdp.memory_space<global>        kind enum {global, ct_local}

and the C++ parameter `value` became `kind`, with `core` becoming the optional
`ct_id`. Following upstream's own migration of test/Dialect/KTDP/add.mlir,
HBM maps to `global`.

Changes here:
  - two C++ construction sites (LowerDescriptorMemory, LowerScalarLoad):
    SpyreMemorySpaceAttr/SpyreMemorySpaceKind::HBM -> MemorySpaceAttr/
    MemorySpaceKind::global
  - 18 .mlir test files, 187 occurrences, all the single form
    spyre_memory_space<HBM> -> memory_space<global>

Nothing here referenced the deleted KTDPAttrInterfaces.h, so no include
changes were needed beyond those already made for the source restructuring.

Verified: spyre-triton-opt builds clean; lit 34/34; pytest 1146 passed,
47 skipped, 0 failed (the 3 inter_tile_reduce numerical failures present at
the previous pin are also resolved).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Yu Chin Fabian Lim <flim@sg.ibm.com>
@fabianlim

Copy link
Copy Markdown
Collaborator Author

Do not merge yet — two temporary pins to revert first

CI is green, but only because this branch points at two unmerged refs. Both must be repinned before merge, in this order:

1. torch-spyre/ktir-cpu#208 — the matching ktir-cpu migration (memory_space rename + tools_ktdpmlir_ktdp.tools). Until it lands, ktir-cpu main has the pre-rename code and every test_numerical[*] fails in the MLIR parse worker (106 failures).

Once it merges, revert ec965a6a ("TEMPORARY: point ktir-cpu at the branch..."), which restores:

"ktir-cpu @ git+https://github.com/torch-spyre/ktir-cpu@main",

The original line is kept inline as a comment in setup.py for exactly this. The empty commit 9e9e89c9 on top is just a CI re-trigger and can go with it.

2. torch-spyre/ktir-mlir-frontend#59 — the cmake>=4.0 pin that fixes the bindings build. The submodule currently points at 233d851, that PR's branch head rather than a commit on main. Re-pin to the squashed commit once it merges.

Worth noting for #59: this branch is what surfaced that bug. 05e7a0f added MLIR_PYTHON_STUBGEN_ENABLED = "ON", activating a latent overflow — MLIR's mlir_generate_type_stubs() joins DEPENDS_TARGETS into a 283-char target name, and CMake 3.x writes it into the file-API reply filename, past NAME_MAX. Failed as errno 63 locally on macOS and errno 36 in CI on Linux.

Current CI state

Install KTDP MLIR bindings ✅ (was ENAMETOOLONG)
lit ✅ 34/34
pytest ✅ 1146 passed, 47 skipped

Matches local results exactly, so nothing is being masked by the temporary pins — they only change where the dependencies come from, not what is tested.

@fabianlim

Copy link
Copy Markdown
Collaborator Author

Update: both PRs green — and the revert list is three pins, not two

CI is now passing on both sides:

DCO tests
this PR ✅ lit 34/34 · pytest 1146 passed, 47 skipped
torch-spyre/ktir-cpu#208 ✅ 1191 (MLIR parser) + 131 (regex parser)

Correcting my note above: there are three temporary pins to unwind, not two. The third is inside ktir-cpu#208.

After torch-spyre/ktir-mlir-frontend#59 merges:

  1. Re-pin the submodule here off 233d851 (that PR's branch head) to the squashed commit on main.
  2. Re-pin ktir-cpu#208's pyproject.toml + uv.lock the same way — both currently reference 233d851.

After ktir-cpu#208 merges: revert ec965a6a here ("TEMPORARY: point ktir-cpu at the branch..."), restoring torch-spyre/ktir-cpu@main in setup.py. The original line is kept inline as a comment. The empty CI-retrigger commit on top goes with it.

Why #59 alone did not unblock ktir-cpu

Worth recording, since it is easy to hit again. #59 pins cmake>=4.0 in build-system.requires, which fixes the bindings build here — triton's bindings install runs with build isolation, so the pin applies.

ktir-cpu's CI installs with --no-build-isolation, which bypasses build-system.requires entirely. The pin never applied there, the build fell back to the runner's CMake 3.x, and it kept failing with the same ENAMETOOLONG even after being pinned to 233d851. ktir-cpu#208 therefore also adds cmake>=4.0 to its own pre-install step. That workflow change may be worth revisiting once #59 is on main, but it is harmless either way.

Not included here, deliberately

An earlier revision of ktir-cpu#208 widened two regexes in the MLIR frontend so rank-0 !ktdp.access_tile<index> and memref<ElemT> parse — both currently raise ValueError, and LowerScalarLoad emits both forms for a scalar tt.load. That is a real bug but unrelated to this migration and untested in that PR, so it was dropped. It needs its own issue against ktir-cpu; noting it here so it is not lost.

Advances the submodule ed069fb6 -> ecfb9ed, picking up
torch-spyre/ktir-mlir-frontend#59 ("Pin cmake>=4.0 and enable stubgen in CI").

This is what unblocks CI. `05e7a0f` (already in this branch's range) added
`MLIR_PYTHON_STUBGEN_ENABLED = "ON"` to the submodule's pyproject.toml, which
activated a latent overflow: MLIR's `mlir_generate_type_stubs()` builds a
283-char target name by joining DEPENDS_TARGETS, and CMake 3.x writes that full
name into its file-API reply filename, overflowing NAME_MAX (255). The bindings
install then died with ENAMETOOLONG — errno 63 locally on macOS, errno 36 in CI
on Linux.

torch-spyre#59 pins cmake>=4.0 in build-system.requires; CMake 4.0 truncates the name and
relies on the trailing hash, so stubgen stays enabled rather than being worked
around here. Note that pin only applies to an isolated PEP 517 build — a
consumer running cmake directly is unaffected (the project itself declares
cmake_minimum_required(VERSION 3.21)), and the cmake it installs lives only in
the ephemeral build environment.

ecfb9ed is the squashed commit on ktir-mlir-frontend main, so this is no longer
a pin to an unmerged branch head.

Signed-off-by: Yu Chin Fabian Lim <flim@sg.ibm.com>
@fabianlim
fabianlim requested review from kcirred and lasch August 18, 2026 21:27
@fabianlim
fabianlim marked this pull request as ready for review August 18, 2026 21:27
@fabianlim
fabianlim merged commit 33a694c into torch-spyre:main Aug 18, 2026
4 of 5 checks passed
@fabianlim
fabianlim deleted the bump-ktir branch August 18, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants